// store/index.js

import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);

const store = new Vuex.Store({
    state: {
        socketMessage: null,
		randomNum:0
    },
    mutations: {
        setSocketMessage(state, message) {
            state.socketMessage = message;
			state.randomNum = Math.floor(Math.random() * 10);
        }
    },
    actions: {
        handleSocketMessage({ commit }, message) {
            commit('setSocketMessage', message);
        }
    },
    getters: {
        getSocketMessage(state) {
			// console.log(55555,state.socketMessage);
            return state.socketMessage + state.randomNum;
        }
    }
});

export default store;